#include"SystemTrayIcon.h" 

SystemTrayIcon::SystemTrayIcon(QWidget *parent):QSystemTrayIcon(QIcon::fromTheme("media-playback-start"), parent){
	m_menu = new QMenu(parent);
	m_menu->setIcon(QIcon::fromTheme("media-playback-start"));
	m_menu->setTitle("Simple Qt Desktop Player");
	
	m_menu->addAction("Simple Qt Desktop Player")->setDisabled(true);
	m_menu->addSeparator();
	
	m_actionRestoreHide = 0;
	
	setContextMenu(m_menu);
	
	connect(this, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(slotActivated(QSystemTrayIcon::ActivationReason)));
	
	show();
}

SystemTrayIcon::~SystemTrayIcon(){
	
}

void SystemTrayIcon::addActions(QAction *prev, QAction *playPause, QAction *next, QAction *stop, QAction *quit, QAction *restoreHide, QAction *configure){
	m_menu->addAction(prev);
	m_menu->addAction(playPause);
	m_menu->addAction(stop);
	m_menu->addAction(next);
	
	m_menu->addSeparator();
	
	m_menu->addAction(configure);
	m_actionRestoreHide = restoreHide;
	m_menu->addAction(m_actionRestoreHide);
	
	m_menu->addSeparator();
	
	m_menu->addAction(quit);
}

void SystemTrayIcon::slotActivated(QSystemTrayIcon::ActivationReason reason){
	if(reason != QSystemTrayIcon::Context)
		m_actionRestoreHide->trigger();
}
